package exercise9;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polyline;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Exercise14_18 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Pane pane=new Pane();

        Polyline polyline = new Polyline();
        ObservableList<Double> list = polyline.getPoints();

        double scaleFactor = 0.0125;
        for (int x = -100; x <= 100; x++) {
            list.add(x + 200.0);
            list.add(200 - scaleFactor * x * x);
        }

        Line line_x=new Line(0, 200, 400, 200);
        Line line_y=new Line(200,0,200,400);

        Text text1 = new Text(300, 200, "X");
        Text text2 = new Text(200, 40, "Y");

        pane.getChildren().addAll(polyline,line_x,line_y,text1,text2);

        Scene scene=new Scene(pane,400,400);
        primaryStage.setTitle("绘制函数");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
